﻿package njClass.bat{
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class ButtonPlus {
		//按钮组动作
		public static function ChooseBtns(btnArray:Array,defaultIndex:Number=0,IsSet:Boolean=false):void {
			var currentID:Number=defaultIndex;
			for (var i=0; i<btnArray.length; i++) {
				if(!IsSet){
					btnArray[i].hitTestState=btnArray[i].upState;
					btnArray[i].addEventListener(MouseEvent.CLICK,countStyle);
				}
			}
			changeStyle();
			
			function countStyle(e:MouseEvent):void {
				if (btnArray.indexOf(e.target)!=currentID) {
					currentID=btnArray.indexOf(e.target);
					changeStyle();
				}
			}
			
			function changeStyle():void {
				for (var j=0; j<btnArray.length; j++) {
					if (j==currentID) {
						btnArray[j].upState=btnArray[j].downState;
					} else {
						btnArray[j].upState=btnArray[j].hitTestState;
					}
				}
			}
		}
	}
}